<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class AdminAuthCheck
{
    public function handle($request, Closure $next, $guard = null)
    {
        if (!Auth::guard($guard)->check()) {
            return redirect('/login');
        }else if(Auth::User()->level<2){
            return redirect('/wx');
        }else if(Auth::User()->level<8){
            return redirect('/company');
        }

        return $next($request);
    }
}
